<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        .box1{
            width: 250px;height: 330px;position: absolute;left: 50px;top: 100px;
        }
        .box1 img{
            width: 100%;height: 100%;
        }
        .mark{
            width: 100px;height: 100px;opacity: .5;position: absolute;background :pink;
            left: 0px;top: 0px;display: none;
        }
        .box2{
            width: 500px;height: 500px;position: absolute;left: 400px;top: 100px;background:yellow;
        }
        .box2 img{
            width: 500px;height: 660px;position: absolute;left: 0;top: 0;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="mark"></div>
        <img src="https://img2.baidu.com/it/u=3355464299,584008140&fm=26&fmt=auto&gp=0.jpg" alt="">
    </div>
    <div class="box2">
        <img src="https://img2.baidu.com/it/u=3355464299,584008140&fm=26&fmt=auto&gp=0.jpg" alt="">
    </div>
</body>
<script>
    // 获取元素
    var obox1=document.querySelector(".box1");
    var obox2=document.querySelector(".box2");
    var omark=document.querySelector(".mark");
    // 绑定事件
    obox1.onmouseover=function(){
        omark.style.display="block";
    }
    obox1.onmouseout=function(){
        omark.style.display="none";
    }
    obox1.onmousemove=function(eve){
        var e=eve||event;
        var l=e.offsetLeft-50;
        var t=e.offsetTop-50;
        omark.style.left=l+"px";
        omark.style.top=t+"px";
    }

</script>
</html>